<?php
/**
  * 用户模型
  */
class UsersModel extends Model
{

  protected $_validate=array(
    array('username','require','用户名必须！',self::MODEL_INSERT),
    array('username','','用户名已经存在',0,'unique',1),
    array('password','require','密码必须！',self::MODEL_INSERT)
    );

  protected $_auto=array(
    array('add_time','time',self::MODEL_INSERT,'function'),
    array('password','md5',self::MODEL_INSERT,'function'),
    array('status',1)  
    );  

    /**
    * 根据用户名和密码获取用户信息
    * @access public 
    * @param string
    * @param string 
    * @return array
    */
	public function findUserByLogin($userName,$pwd)
	{
		$where['username']=$userName;
		$where['password']=md5($pwd);
		$where['status']=1;
		return $this->field('id')->where($where)->find();
	}
}
?>